package com.frxuexi.park2305.my

import com.frxuexi.lib_base.http.ApiService
import com.frxuexi.lib_base.http.RequestType
import com.frxuexi.lib_base.mvi.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MyViewModel @Inject constructor(val apiService: ApiService):BaseViewModel<MyIntent>() {
    override fun handleIntent(it: MyIntent) {
        when(it){
            is MyIntent.getMyPark->httpRequest(apiService.getParksByType("标准车位"))
            is MyIntent.getMyVisit->httpRequest(apiService.getVisitByName(it.unmae),RequestType.SELECT_VISIT)
            is MyIntent.getMyRepair->httpRequest(apiService.getRepairsByUname(it.uname),RequestType.SELECT_REPAIR)
            is MyIntent.getMyTask->httpRequest(apiService.getMyTasks(it.uid),RequestType.SELECT_TASK)
            is MyIntent.getMyAppPark->httpRequest(apiService.getParksByArea(1))
            is MyIntent.approvePark->httpRequest(apiService.approvePark(it.id,it.status),RequestType.UPDATE)
            is MyIntent.getVisits->httpRequest(apiService.getVisits(),RequestType.SELECT_VISIT)
            is MyIntent.approveVisit->httpRequest(apiService.approveVisit(it.id),RequestType.UPDATE)
            is MyIntent.rejectVisit->httpRequest(apiService.rejectVisit(it.id),RequestType.UPDATE)
            is MyIntent.getNews->httpRequest(apiService.getNews(),RequestType.SELECT_NEWS)
        }
    }
}